home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
prog
/
proxy14.arj
/
TOPSORT.PRX
< prev
Wrap
Text File
|
1991-10-04
|
400b
|
12 lines
// transforms a partial order into a total order
// topsort: map(string,string) x set(string) -> seq(string)
topsort(g,nodes;x,n) { x={x:x<-nodes;x notin rng g};
if(x=={}) return [];
else n=oneof x;
return [n] conc topsort(g ds {n}, nodes diff {n});};
nodes = {"c1","c2","c3","c4","c5"};
g = {"c1" -> "c3", "c2" -> "c3", "c2" -> "c4", "c3" -> "c5",
"c4" -> "c5"};
end